
<div class="entry">
<div class="goods-detail-left">
	<div class="upload_images item">
		<h4 class="tab-title">商品图片管理</h4>
		<div class="tab-content">
		<div class="title">商品封面(建议尺寸:500*500)：</div>
		<br>
		
		<div class="image_show">
			{{#if $Cache.new_goods.preview_img_url}}
				<img bind-src="{{$Cache.new_goods.preview_img_url}}?imageView/1/w/160">
			{{/if}}
			<img-uploader
				upload-server-url="{{config.other.upload_image}}"
				text="上传封面图片"
				bind-input-key="$Cache.new_goods.preview_img_url"
				bind-status="{{'$Cache.shelves.preview_img_url_upload_status'}}"
				one-way="true"
				style="display:inline-block;"
				max-width="512"
				>
			</img-uploader>
		</div>
		<div class="title">商品详情图：
			<m-img-uploader 
				max-num="{{config.server_config.storeImagesNumber}}"
				max-width="1200"
				bind-status="{{'$Cache.shelves.preview_img_url_upload_status'}}"
				upload-callback="{{'$Event.mul_img_upload.cb'}}"
				upload-error-callback="{{'$Event.mul_img_upload.err_cb'}}"
				handle-progress-callback="{{'$Event.mul_img_upload.hp_cb'}}" 
				upload-progress-callback="{{'$Event.mul_img_upload.up_cb'}}"
				bind-input="{{'$Cache.mul_img_upload.imgs'}}">
				<button>{{$Cache.mul_img_upload.info||"点击批量上传"}}</button>
			</m-img-uploader>
		</div>
		<br>
		<br>
		<br>
		<div>
			{{#each $Cache.shelves.detail_img_urls}}
			<div class="with-inset-shadow" style="{{url&&'float: left; margin:5px 5px; box-shadow: 1px 1px 9px;'}}">
				<img-uploader
					bind-input-key="url"
					url="{{url}}"
					bind-status="{{'status'}}"
					text="上传商品详情图"
					style="float: left; "
					max-width="1200"
					>
				</img-uploader>
			</div>
			{{/each}}
		</div>
		</div>
	</div>

	<div class="base_info item">
		<h4 class="tab-title">商品基本信息管理</h4>
		<div class="tab-content">
		<div class="goods-name item">商品名称：<input type="text" name="goods-title" class="goods-title android" bind-input="{{'$Cache.new_goods.goods_name'}}" value="{{$Cache.new_goods.goods_name}}" /></div>

		<div class="kinds item {{$Cache.new_goods.card_factory_list.0&&'hidden'}}">
			选择标签：
			{{#each $Cache.shelves.bus_tags}}
				<div event-click="{{_checked?'$Top.$Event.tag.unuse_tag':'$Top.$Event.tag.use_tag'}}" class="kinds-item {{_checked&&'focus'}}" title="{{_checked?'点击移除':'点击添加'}}">{{tag_name}}</div>
			{{/each}}
			<div class="add-tag" style="display:inline-block;">
				<input type="text" class="goods-tag android" value="{{$Cache.tag.new_tag_name}}" bind-input="{{'$Cache.tag.new_tag_name'}}">
				<button event-click="{{'$Event.tag.add_new_tag'}}">添加标签</button>
			</div>
		</div>

		<div class="classify item">
		商品类目
			<android:selectSearch style="text-align: left;" use-value-as-result="true" value="{{$Cache.new_goods.classify_id}}" bind-input="{{'$Cache.new_goods.classify_id'}}">
			{{#> "goods-detail-classify-tree-item","$Cache.goods_detail.classify_tree",$Cache.goods_detail.classify_tree.childs.length}}
			</android:selectSearch>
		</div>
<xmp type="template" name="goods-detail-classify-tree-item">
	{{#each childs}}
	<optionItem deep="{{deep}}" value="{{classify._id}}">
		{{$Caller.$Private.prefix}} 
		{{classify.classify_name}}
	</optionItem>
	{{#> "goods-detail-classify-tree-item","$This",childs.length}}
	{{/each}}
	<script type="text/vm">
	function(vm) {
		var optionItemNode = vm.getOneElementByTagName("optionItem");
		jSouper.onElementPropertyChange(optionItemNode, "deep", function(attrKey, value) {
			vm.set("$Private.prefix", Array(~~value).join("　") + "┗");
		}, true);
	}
	</script>
</xmp>
		<div class="price item">原价（可不填，默认为现价）：￥<input type="text" name="goods-price" class="goods-price android" bind-input="{{'$Cache.new_goods.original_price'}}" value="{{$Cache.new_goods.original_price||$Cache.new_goods.price||''+'（现价）'}}" /></div>

		<!-- <div class="price item">VIP价（可不填，默认为现价）：￥<input type="text" name="goods-price" class="goods-price android" bind-input="{{'$Cache.new_goods.vip_price'}}" value="{{$Cache.new_goods.vip_price||$Cache.new_goods.price||''+'（现价）'}}" /></div> -->

		<div class="price item">现价：￥<input type="text" name="goods-price" class="goods-price android" bind-input="{{'$Cache.new_goods.price'}}" value="{{$Cache.new_goods.price}}" /></div>

		<div class="price item">返现：￥<input type="text" name="goods-price" class="goods-price android" bind-input="{{'$Cache.new_goods.back_cash'}}" value="{{$Cache.new_goods.back_cash}}" /></div>

		<!-- <div class="fare item">运费：<input type="text" name="goods-fare" class="goods-fare" bind-input="{{'$Cache.new_goods.fare'}}" value="{{$Cache.new_goods.fare}}" /></div> -->

		<div class="fare item">库存：<input type="text" name="goods-num" class="goods-num android" bind-input="{{'$Cache.new_goods.num'}}" value="{{$Cache.new_goods.num}}" /></div>

		<div class="fare item">单位：<input type="text" name="goods-unit" class="goods-unit android" bind-input="{{'$Cache.new_goods.unit'}}" value="{{$Cache.new_goods.unit||'件'}}" /></div>
		
		<div class="goods-express item">
			运费：
			<android:selectSearch datalist-key="$Cache.bus.goods_detail.express_list" use-value-as-result="true" value="{{$Cache.new_goods.express_id}}" search-placeholder="选择运费模板" bind-input="{{'$Cache.new_goods.express_id'}}">
			    {{#each $Cache.bus.goods_detail.express_list}}
			    <optionItem value="{{_id}}" search-data="{{name+express_com}}">{{name}}；{{express_com}} ￥{{#Fixed express_price}}</optionItem>
			    {{/each}}
			</android:selectSearch>
		</div>
		<div class="card-factory item">
			所属专区（和会员卡相关的商品专区）：
			{{#if $Cache.new_goods._id}}
				{{#if $Cache.bus.selected_card_factory}}
				<span title="{{$Cache.bus.selected_card_factory.info.intro}}">{{$Cache.bus.selected_card_factory.info.name}}</span>
				{{#else}}
				<i>任何人可买（无需指定会员卡）</i>
				{{/if}}（不可修改）
			{{#else}}
				（提交后不可修改）
				<android:selectSearch datalist-key="$Cache.bus.goods_detail.card_factory_list" use-value-as-result="true" value="{{$Cache.new_goods.card_factory_list.0}}" search-placeholder="选择商品所属专区" bind-input="{{'$Cache.new_goods.card_factory_list.0'}}" event-change="{{'$Event.goods_detail.on_card_factory_list_change'}}">
				    {{#each $Cache.bus.goods_detail.card_factory_list}}
				    <optionItem value="{{_id}}" title="{{info.intro}}" search-data="{{info.name+_id}}">{{info.name}}</optionItem>
				    {{/each}}
				</android:selectSearch>
			{{/if}}
		</div>
		<div class="amount_result item">
		</div>
		{{#if bus_loginer.permission.can_only_online_pay}}
		<div class="only_online_pay item">
			<android:switch checked="{{$Cache.new_goods.only_online_pay}}" bind-input="{{'$Cache.new_goods.only_online_pay'}}" >禁止商品货到付款</android:switch>
		</div>
		{{/if}}
		<div class="summary item">
			<div class="title">商品简述：</div>
			<br>
			<textarea name="summary" class="goods_summary android" placeholder="不超过150字" maxlength="150" bind-input="{{'$Cache.new_goods.intro'}}">{{$Cache.new_goods.intro}}</textarea>
		</div>
		</div>
	</div>
	<div class="summary item">
		<h4 class="tab-title">商品详细介绍</h4>
		<div class="tab-content">
		<ueditor 
			style="display: inline-block;"
			bind-input="{{'$Cache.new_goods.detail_content'}}" 
			bind-status="{{'$Cache.shelves.goods_detail_content_img_upload_status'}}"
			value="{{$Cache.new_goods.detail_content}}" >
			<!-- 但init-key所对应的内容开始存在时，初始化编辑区域 -->
		</ueditor>
		</div>
	</div>
</div>
<div class="goods-detail-right">
{{#if $Cache.new_goods.goods_args_map}}
	<div class="some-goods_args-goods-list">
		<h4 class="tab-title">同类商品列表</h4>
		<div class="tab-content">
			<table class="paper-table goods-list">
				<thead>
					<td></td>
					<td>商品名（点击编辑商品）</td>
				</thead>
				{{#each $Cache.some_goods_args_goods_list}}
				<tr>
					<td><img src="{{preview_img_url}}?imageView/1/w/25/h/25" alt="{{goods_name}}的封面图"></td>
					<td class="goods-list-item {{$Top.$Cache.new_goods._id==_id&&'editing'}}" event-click="{{'$Top.$Event.some_goods_args_goods_list.edit_current_goods'}}">{{goods_name}} （{{using_goods_args}}）</td>
				</tr>
				{{/each}}
			</table>
			<div class="hr"></div>
			<div class="add-some-goods_args-goods">
				<android:paperbutton event-click="{{'$Event.some_goods_args_goods_list.add'}}">添加同类商品</android:paperbutton>
			</div>
		</div>
	</div>
	<div class="current-args">
		<h4 class="tab-title">商品所属可选属性</h4>
		<div class="tab-content">
		{{#each $Cache.new_goods.goods_args_map.info.args}}
			<android:selectSearch placeholder="{{title}}" title="{{title}}" value="{{$Top.$Cache.new_goods.using_goods_args[$Index]}}" bind-input="{{'$Top.$Cache.new_goods.using_goods_args.'+$Index}}" use-value-as-result="true" >
				{{#each items}}
					{{#> "choose-goods_args-item-"+type}}
				{{/each}}
			</android:selectSearch>
		{{/each}}
		</div>
	</div>
{{/if}}
	<div class="choose_args item">
		<h4 class="tab-title">商品可选属性编辑</h4>
		{{#each $Cache.new_goods.goods_args_map.info.args}}
		<div class="edit-goods_args">
			<android:input value="{{title}}" bind-input="{{'title'}}" label="属性名：" description="请用简单易懂的属性名称" event-change="{{'$Top.$Event.goods_args_map.upload'}}"></android:input>
			<android:paperbutton class="remove-args" title="删除这个属性" event-click="{{'$Top.$Event.goods_args_map.remove'}}"><i class="icon-remove2"></i></android:paperbutton>
			<div class="hr"></div>
			<div class="goods_args-items">
				<h5>现有属性可选项</h5>
				{{#if !items.length}}<i>暂无，请添加</i>{{/if}}
				{{#each items}}
				<div class="show-goods_args-item" event-click="{{'$Top.$Event.goods_args_map.edit_goods_args_map_item'}}">{{#> "show-goods_args-item-"+type}}</div>
				{{/each}}
			</div>
			<div class="hr"></div>
			<div class="add_or_update-goods_args_item {{#IndexOf items,_new_goods_args_map,'to-update','to-add'}}">
				<h5 class="tab-title in-add">添加属性可选项</h5>
				<h5 class="tab-title in-update">修改属性可选项</h5>
				<div class="tab-content ">
					<div class="add_or_update-goods_args-item">
					{{#> "add_or_update-goods_args-item-"+_new_goods_args_map.type}}
					</div>
					<android:selectSearch use-value-as-result="true" value="{{_new_goods_args_map.type}}" placeholder="选择属性类别" search-placeholder="" bind-input="{{'_new_goods_args_map.type'}}">
						{{#each $Top.$Cache.GOODS_ARGS_MAP_TYPE_array}}
						<optionItem value="{{value}}" search-data="{{key+value}}">{{key}}属性</optionItem>
						{{/each}}
					</android:selectSearch>
					<android:paperbutton class="in-add" style="display:inline-block;" event-click="{{'$Top.$Event.goods_args_map.add_goods_args_map_item'}}"><i class="icon-plus"></i>确定添加</android:paperbutton>
					<android:paperbutton class="in-update" style="display:inline-block;" event-click="{{'$Top.$Event.goods_args_map.update_goods_args_map_item'}}">提交修改</android:paperbutton>
					<br>
					<android:paperbutton class="in-update" style="display:inline-block;" event-click="{{'$Top.$Event.goods_args_map.remove_goods_args_map_item'}}">删除属性项</android:paperbutton>
					<android:paperbutton class="in-update" style="display:inline-block;" event-click="{{'$Top.$Event.goods_args_map.cancel_update_goods_args_map_item'}}">取消修改</android:paperbutton>
				</div>
			</div>
		</div>
		{{/each}}
		<div class="create-choose-args" event-click="{{'$Event.goods_args_map.add_arg'}}">
			<i class="icon-plus"></i>
			添加可选属性
		</div>
	</div>
</div>
</div>
<xmp type="template" name="choose-goods_args-item-text">
	<optionItem search-data="{{type+value}}" value="{{value}}">{{value}}</optionItem>
</xmp>
<xmp type="template" name="choose-goods_args-item-image">
	<optionItem search-data="{{type+value}}" style="background-image:url({{src}});" value="{{value}}">{{value}}</optionItem>
</xmp>
<xmp type="template" name="choose-goods_args-item-color">
	<optionItem search-data="{{type+value}}" style="background-color:{{color}};" value="{{value}}">{{value}}</optionItem>
</xmp>
<xmp type="template" name="show-goods_args-item-text">
	<android:paperbutton>{{value}}</android:paperbutton>
</xmp>
<xmp type="template" name="show-goods_args-item-image">
	<android:paperbutton bind-style="background-image:url({{src}}?imageView2/1/w/36/h/36);height:36px;width:36px;" title="{{value}}"></android:paperbutton>
</xmp>
<xmp type="template" name="show-goods_args-item-color">
	<android:paperbutton bind-style="background-color:{{color}};height:36px;width:36px;" title="{{value}}"></android:paperbutton>
</xmp>
<xmp type="template" name="add_or_update-goods_args-item-text">
	<android:input value="{{_new_goods_args_map.value}}" bind-input="{{'_new_goods_args_map.value'}}" label="属性选项描述"></android:input>
</xmp>
<xmp type="template" name="add_or_update-goods_args-item-image">
	<img-uploader
		upload-server-url="{{$Top.config.other.upload_image}}"
		text="属性图片"
		url="{{_new_goods_args_map.src}}"
		bind-input-key="_new_goods_args_map.src"
		bind-status="{{'_new_goods_args_map._upload_status'}}"
		style="display:inline-block;width:64px;height:64px;"
		max-width="128"
		>
	</img-uploader>
	<android:input value="{{_new_goods_args_map.value}}" bind-input="{{'_new_goods_args_map.value'}}" label="图片描述"></android:input>
</xmp>
<xmp type="template" name="add_or_update-goods_args-item-color">
	<color-picker value="{{_new_goods_args_map.color}}" bind-input-key="_new_goods_args_map.color" style="display:inline-block;" ></color-picker>
	<android:input value="{{_new_goods_args_map.value}}" bind-input="{{'_new_goods_args_map.value'}}" label="颜色描述"></android:input>
</xmp>
<style>
	.with-inset-shadow{
		position: relative;
	}
	.with-inset-shadow::before
	{
		display:block;
		content:'';
		position:absolute;
		width:100%;
		height:100%;
		-moz-box-shadow:inset 0px 0px 3px 1px rgba(0,0,0,0.5);
		-webkit-box-shadow:inset 0px 0px 3px 1px rgba(0,0,0,0.5);
		box-shadow:inset 0px 0px 3px 1px rgba(0,0,0,0.5);
		border-radius: 2%;
		pointer-events: none;
	}
	.goods-detail-left{
		width: 68%;
		display: inline-block;
		vertical-align: top;
		border-right: 1px solid #ddd;
	}
	.goods-detail-right{
		width: 31%;
		display: inline-block;
		vertical-align: top;
	}
	h5{
		background-color: #DDD;
	}
	.create-choose-args{
		width:80%;
		border:3px dotted #555558;
		padding:12px 0;
		text-align: center;
		cursor: pointer;
		border-radius: 6px;
	}
	.edit-goods_args{
		width:90%;
		border:1px dotted #555558;
		padding:6px;
		border-radius: 6px;
		margin-bottom: 6px;
	}
	.edit-goods_args>.android-input{
		display: inline-block;
	}
	.edit-goods_args .remove-args{
		display: inline-block!important;
	}
	.edit-goods_args .remove-args .paper-container spaninner{
		padding: 0 12px!important;
		min-width: auto!important;
	}
	.add_or_update-goods_args_item .android-input{
		display: inline-block;
		vertical-align: middle;
		margin-left: 6px;
	}
	.add_or_update-goods_args_item.to-update .in-add{
		display: none!important;
	}
	.add_or_update-goods_args_item.to-add .in-update{
		display: none!important;
	}
	.show-goods_args-item{
		display: inline-block;
		vertical-align: top;
	}
	.show-goods_args-item .paper-container spaninner{
		padding: 0 2px!important;
		min-width: auto!important;
	}
	.show-goods_args-item .paper-container{
		background-color: transparent!important;
	}

	.goods-list .goods-list-item{
		cursor: pointer;
	}
	.goods-list .goods-list-item.editing{
		background-color: #DDD;
		cursor: auto;
	}
</style>